/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ChatNI;


import common.*;
import java.net.InetAddress;

/**
 * FabriqueMessage
 * Class specific for building the messages without the correspondence with a file transfer
 * @author Duy Duc , Metangmo 
 */
public class FabriqueMessage {
    
    /**
     * creerMessage:
     * function builds the different types of message without the correspondence with a file transfer
     * @param type
     *        Type of the built message ( HELLO, BYE, TEXT )
     * @param addr
     *        IP Address of the recipient
     * @param username
     *        Nickname of the LocalUser
     * @param boo
     *        True/False signifies a demand of connection/a demand of addition in a list of user for the HELLO message
     * @param texte
     *        Content of TEXT message
     * @return
     *        Built message
     */
    public Message creerMessage(FabriqueMessage.TypeMessage type, InetAddress addr, String username, Boolean boo, String texte){
        Message mess = null;
        
        //Create different types of message
        switch(type)
        {
            case HELLO: mess = new Hello(username,addr,boo);break;
            case TEXT: mess = new Text(addr,texte);break;
            case BYE: mess = new Bye(addr);break;
        }
        return mess;
    }

 
    /**
     * TypeMessage
     * An enumeration identifies the different types of message that can be created by FabriqueMessage
     */
    public enum TypeMessage {
       
        /**
         * Message is sent following the connection of the LocalUser to the ChatSystem
         * It can be a HELLO-TRUE or a HELLO-FALSE
         */
        HELLO,

       /**
         * Text message is sent to a distance chosen user
         */
        TEXT,

        /**
         * Message is sent resulting of the disconnection of the LocalUser from the ChatSystem  
         */
        BYE
    }
    
}
